<template>
  <div class="app-container">
    <el-form ref="form" :model="form" label-width="80px" inline>
      <el-form-item  label="操作名称">
        <el-input style="width: 80%;"  v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label="创建">
        <el-col :span="11">
          <el-date-picker
            v-model="form.timeRange"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
        </el-col>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit(form)">查询</el-button>
        <el-button  @click="onReset(form)">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
    >
      <el-table-column
        type="index"
        width="50">
      </el-table-column>
      <el-table-column align="center" label="日志内容" width="200">
        <template slot-scope="scope">
          {{ scope.row.urlName }}
        </template>
      </el-table-column>
      <el-table-column label="操作人用户名" width="150"  align="center">
        <template slot-scope="scope">
          {{ scope.row.operator }}
        </template>
      </el-table-column>
      <el-table-column label="操作人姓名" width="150" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.operatorName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="ip地址" width="200" align="center">
        <template slot-scope="scope">
          {{ scope.row.ip }}
        </template>
      </el-table-column>
      <el-table-column label="创建时间" width="200" align="center">
        <template slot-scope="scope">
          {{ scope.row.createTime }}
        </template>
      </el-table-column>
    </el-table>
    <div class="block" style="margin-top: 40px">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page.sync="currentPage"
        :page-size="100"
        layout="prev, pager, next, jumper"
        :total="1000">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { getSystemLogList } from '@/api/systemLog'

export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: 'success',
        draft: 'gray',
        deleted: 'danger'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      list: null,
      listLoading: false,
      form: {},
      equipmentDetail: {},
      currentPage: 1,
      dialogFormVisible: false,
      diaLook: true,
      operate: ''
    }
  },
  created() {
    this.fetchData(this.form)
  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
    },
    handleCurrentChange(val) {
      this.form.pageNum = val
      getSystemLogList(this.form).then(res => {
        this.list = res.data.rows
      })
    },
    handleEdit(row) {
    },
    onSubmit(param) {
      getSystemLogList(param).then(res => {
        this.list = res.data.rows
      })
    },
    fetchData(param) {
      getSystemLogList(param).then(res => {
        this.list = res.data.rows
      })
    }
  }
}
</script>
